/*
 * Copyright 2003-2006 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

%module(package = "argot") common

%import "type.i"

%{
	#include "Types.h"
	#include "common/BigEndianSignedByte.h"
	#include "common/BigEndianSignedInteger.h"
	#include "common/BigEndianSignedLong.h"
	#include "common/BigEndianSignedShort.h"
	#include "common/BigEndianUnsignedByte.h"
	#include "common/BigEndianUnsignedInteger.h"
	#include "common/BigEndianUnsignedLong.h"
	#include "common/BigEndianUnsignedShort.h"
	#include "common/Empty.h"
	#include "common/Endian.h"
	#include "common/Error.h"
	#include "common/U8Ascii.h"
	#include "common/U8Boolean.h"
	#include "common/U16ArrayByte.h"
	#include "common/U32ArrayByte.h"
	#include "common/U32UTF8.h"
%}


%define %make_type_class(typename, pyname)

%immutable pyname::name;

%inline
{
	typedef struct pyname
	{
		void* xxx;
	} pyname;
}


%extend pyname
{
	static int read(type_input_stream * instream, type_element * element)
	{
		return typename##_read(instream, element, 0);
	}

	static int write(type_output_stream * outstream, void * o, type_element * element, void * data)
	{
		return typename##_write(outstream, o, element, 0);
	}

	const type_name* name;
}

%ignore pyname::xxx;

%{
	type_name* pyname##_name_get(pyname* self)
	{
		return &typename##_name;
	}
%}

//%add_readonly_prop(pyname, type_name*, name, pyname##_name_get)



%enddef


%include "common/BigEndianSignedByte.h"
%make_type_class( sint8, SInt8 );

%include "common/BigEndianSignedShort.h"
%make_type_class( sint16, SInt16 );

%include "common/BigEndianSignedInteger.h"
%make_type_class( sint32, SInt32 );

%include "common/BigEndianSignedLong.h"
%make_type_class( sint64, SInt64 );


%include "common/BigEndianUnsignedByte.h"
%make_type_class( uint8, UInt8 );

%include "common/BigEndianUnsignedShort.h"
%make_type_class( uint16, UInt16 );

%include "common/BigEndianUnsignedInteger.h"
%make_type_class( uint32, UInt32 );

%include "common/BigEndianUnsignedLong.h"
%make_type_class( uint64, UInt64 );

%include "common/Empty.h"
%make_type_class( empty, Empty );

%include "common/Endian.h"

%include "common/Error.h"

%inline
{
	typedef struct Error
	{
		void* xxx;
	} Error;
}

%extend Error
{
	static int read(type_input_stream * instream, type_element * element)
	{
		return error_read(instream, element, 0);
	}

	static int write(type_output_stream * outstream, void * o, type_element * element, void * data)
	{
		return error_write(outstream, o, element, 0);
	}
}


%include "common/U8Ascii.h"
%make_type_class( u8ascii, U8Ascii );

%include "common/U8Boolean.h"
%make_type_class( bool, U8Boolean );

%include "common/U16ArrayByte.h"
%make_type_class( u16binary, U16Binary );

%include "common/U32ArrayByte.h"
%make_type_class( u32binary, U32Binary );

%include "common/U32UTF8.h"
%make_type_class( u32utf8, U32Utf8 );
